package com.by.wx.mamager;

import org.junit.Test;

import com.by.wx.service.WxService;
import com.by.wx.util.Util;
import com.by.wx.util.UtilsA;

public class TemplateMessageManager {

	/**
	 * 设置行业
	 */
	@Test
	public void set() {
		String at = WxService.getAccessToken();
		String url = "https://api.weixin.qq.com/cgi-bin/template/api_set_industry?access_token=ACCESS_TOKEN";
		url = url.replace("ACCESS_TOKEN", at);
		// 这里你可以写一个类来转换成json串
		String data = "{ \n" + " \"industry_id1\":\"3\",\n" + " \"industry_id2\":\"11\"\n" + "}";
		String result = UtilsA.post(url, data);
		System.out.println(result);
	}

	/**
	 * 获取行业
	 */
	@Test
	public void get() {
		String at = WxService.getAccessToken();
		String url = "https://api.weixin.qq.com/cgi-bin/template/get_industry?access_token=ACCESS_TOKEN";
		url = url.replace("ACCESS_TOKEN", at);
		String result = UtilsA.get(url);
		System.out.println(result);
	}

	/**
	 * 发送模板消息 简历反馈提醒
	 */
	@Test
	public void sendTemplateMessage() {
		String at = WxService.getAccessToken();
		String url = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=ACCESS_TOKEN";
		url = url.replace("ACCESS_TOKEN", at);
		// 这里的data可以通过面向对象的方式来处理
		String data = "{\"touser\":\"oK3Yq0sQ1n2pelXDXUMEKIuJb-gU\",\"template_id\":\"2uyeY55w9m_l1zBPGlqvuLUosJ4jY0TnOxXSUe8iW54\",\"url\":\"http://weixin.qq.com\",   \"data\":{\"first\": {\"value\":\"您有新的反馈信息啦！\",\"color\":\"#abcdef\"},\"company\":{\"value\":\"广州宝雅智能科技有限公司\",\"color\":\"#fff000\"},\"time\": {\"value\":\"2000年12月12日\",\"color\":\"#1f1f1f\"},\"result\": {\"value\":\"面试通过\",\"color\":\"#abc123\"},\"remark\":{\"value\":\"请和本公司人事专员联系！\", \"color\":\"#abc123\"} }}";
		String result = UtilsA.post(url, data);
		System.out.println(result);
	}
}
